<template>
  <el-menu default-active="1" class="el-menu-demo" mode="horizontal" @select="handleSelect">
    <h1 style="float: left;line-height: 60px;padding: 0 20px;">山东财经大学区块链打卡辅助平台</h1>
  </el-menu>
  <el-container>
    <el-main style="">
      <el-row style="width: 100%;margin-top: 5%;">
        <el-col :xs="{span:22,offset:1}" :sm="{span:16,offset:4}" :md="{span:10,offset:5}" :lg="{span:14,offset:5}">
          <el-card style="" shadow="never" :style="{width:'100%'}">
            <h2 style="margin: 0 0 20px 0;font-size: 1.4rem;">问题反馈</h2>
            <el-form label-width="3rem">
              <el-form-item label="学号">
                <el-input type="text" v-model="study_id" placeholder="学号"></el-input>
              </el-form-item>
              <el-form-item label="反馈内容">
                <el-input rows="15" type="textarea" v-model="content" placeholder="具体内容"></el-input>
              </el-form-item>
              <div style="text-align: right">
                <el-button type="primary" plain @click="sendText">发送</el-button>
              </div>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
    </el-main>
  </el-container>
</template>

<script>
export default {
  name: "contact",
  data() {
    return {
      study_id: '',
      content: ''
    }
  },
  methods: {
    sendText() {
      if (this.content.length<=5 || this.study_id.length<=10){
        this.$ElMessage.error({
          message:'请检查学号是否有误，反馈内容至少5字。'
        })
        return
      }
      let url = '/api/sendmail'
      this.$axios.post(url, {
        content: this.content,
        study_id: this.study_id
      }).then(res => {
        this.$ElMessage.success({
          message: '提交成功'
        })
        setTimeout(() => {
          this.$router.push('/admin')
        }, 1500)
      }).catch(res => {
        this.$ElMessage.error({
          message: '提交失败'
        })
        console.log(res)
      })
    }
  }
}
</script>

<style scoped>

</style>